N = 1000000
isp = [1 for i in xrange(N)]
p = []

isp[0], isp[1] = 0, 0

for i in xrange(2, N):
    if isp[i]:
        p.append(i)
        for j in xrange(i + i, N, i):
            isp[j] = 0

ans = 0
count = 0

def f(n):
    sn = str(n)
    if n < 10 and isp[n]:
        return True
    a = []
    for i in xrange(len(sn) -1):
        a.append(int(sn[i + 1:]))
        a.append(int(sn[:len(sn) - i - 1]))
    if n == 3797:
        print a
    for aa in a:
        if not isp[aa]:
            return False
    return True

for n in p:
    if n > 10:
        if f(n):
            ans += n
            count += 1

print count, ans


